﻿namespace Hotel.Web.Models
{
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using Hotel.Module.Management.Models;
    using Hotel.Module.Resources;

    public class CheckOut
    {
        public static CheckOut FromDomainModel(Order order)
        {
            CheckOut model = null;
            if (order != null)
            {
                model = new CheckOut();
                model.OrderNumber = order.ID;
                model.CustomerName = string.Format("{0} {1}", order.FName, order.LName);
                model.Services = new List<Service>();
                using (HotelResourcesController m_ResourcesController = Helpers.ServiceLocator.Instance.GetService(typeof(IResourseManagment)) as HotelResourcesController)
                {
                    foreach (var serviceId in order.IncludedServices)
                    {
                        Hotel.Module.Resources.Models.Service domainService = m_ResourcesController.GetServiceByID(serviceId);
                        Service service = Service.FromDomainModel(domainService);
                        model.Services.Add(service);
                    }
                }
            }
            return model;
        }

        [Display(ResourceType = typeof(Hotel.Web.Views.CheckInOut.CheckInOutResources), Name = "OrderID")]
        public int OrderNumber { get; set; }

        [Display(ResourceType = typeof(Hotel.Web.Views.CheckInOut.CheckInOutResources), Name = "CustomerName")]
        public string CustomerName { get; set; }

        [Display(ResourceType = typeof(Hotel.Web.Views.CheckInOut.CheckInOutResources), Name = "Services")]
        public List<Service> Services { get; set; }

        [Display(ResourceType = typeof(Hotel.Web.Views.CheckInOut.CheckInOutResources), Name = "PrintMode")]
        public string ActionType
        {
            get;
            set;
        }

        public string CheckOutPrint { get; set; }
    }
}